﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Emgu.CV;
using Emgu.CV.Structure;
using System.Drawing;
using Emgu.CV.UI;
using Emgu.CV.Stitching;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Image<Bgr, Byte>[] imgs = new Image<Bgr, byte>[2] {
            new Image<Bgr,byte>(@"C:\Users\jiangzh\Documents\Youcam\Snapshot_20131002_1.JPG"),
            new Image<Bgr,byte>(@"C:\Users\jiangzh\Documents\Youcam\Snapshot_20131002.JPG")
            };
            using (Stitcher stitcher = new Stitcher(
                //This indicate if the Stitcher should use GPU for processing. 
                //There is currently a bug in Open CV such that GPU processing cannot produce the correct result. 
                //Must specify false as parameter. Hope this will be fixed soon to enable GPU processing
                  false
                  ))
            {
                Image<Bgr, Byte> result = stitcher.Stitch(imgs);
                // code to display or save the result 

                using (ImageViewer viewer = new ImageViewer(result))
                {
                    viewer.ShowDialog();
                }
            }
            foreach (var img in imgs)
            {
                img.Dispose();
            }
        }
    }
}
